Alternative cell clustering method using DynamicTreeCut

We also provide an alternative way to cluster cells based on hierarchical clustering. The tree is cut using the DynamicTreeCut R package.

Cell clustering

# Perform hierarchical cluster algorithm and cut the tree using DynamicTreeCut package
pbmc_scigenex <- cell_clust(pbmc_scigenex, min_cluster_size = 4)
##  ..cutHeight not given, setting it to 1.12  ===>  99% of the (truncated) height range in dendro.
##  ..done.


Heatmap visualization

You can visualize your clustering result with the plot_heatmap function using all the cells… …or the core cells of each cluster provided by DynamicTreeCut.

# Heatmap of the top genes for each pattern of co-expressed genes
plot_heatmap(pbmc_scigenex,
             use_top_genes = TRUE,
             cell_order = names(sort(pbmc_scigenex@cell_clusters$labels)),
             line_size = 2)
## |--  Centering matrix. 
## |--  Ordering cells. 
## |--  Ceiling matrix. 
## |--  Flooring matrix. 
## |--  Plotting heatmap.


…or the core cells of each cluster provided by DynamicTreeCut.

# Using core cells of each cell clusters
plot_heatmap(pbmc_scigenex,
             use_top_genes = TRUE,
             use_core_cells = TRUE,
             line_size = 2)
## |--  Centering matrix. 
## |--  Ordering cells based on hierarchical clustering. 
## |--  Ceiling matrix. 
## |--  Flooring matrix. 
## |--  Plotting heatmap.


Mapping cluster on UMAP

# _______________________
# Add SciGeneX result on Seurat object
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Add SciGeneX clustering result in metadata of Seurat object
pbmc_seurat[["scigenex_cell_clusters"]] <- pbmc_scigenex@cell_clusters$labels

# Use genes found by SciGeneX as feature selection results
pbmc_seurat@assays$RNA@var.features <- get_genes(pbmc_scigenex)


# _______________________
# Run the classical pipeline of Seurat
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Scaling data
pbmc_seurat <- ScaleData(pbmc_seurat,
                         features = rownames(pbmc_seurat))

# Perform principal component analysis
pbmc_seurat <- RunPCA(pbmc_seurat,
                      features = VariableFeatures(object = pbmc_seurat))

# Cell clustering 
pbmc_seurat <- FindNeighbors(pbmc_seurat, dims = 1:10)
pbmc_seurat <- FindClusters(pbmc_seurat, resolution = 0.5)

# Dimension reduction
pbmc_seurat <- RunUMAP(pbmc_seurat, dims = 1:10)

# Map SciGeneX cell clustering results on UMAP
col_rainbow = c("#E96767", "#EC9342", "#FFCA3A", "#8AC926", "#4DADE8",
                "#9579B9", "#E25CB4", "#EF9292", "#7BC4EE", "#F2B57D", 
                "#FFDA77", "#B6E36A", "#9F1717", "#517416", "#9F1717",
                "#AE5B11")
DimPlot(pbmc_seurat, reduction = "umap", group.by = "scigenex_cell_clusters",
        cols = col_rainbow)